package study.cdc.canal.blogic;

import com.alibaba.otter.canal.protocol.CanalEntry;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import study.cdc.canal.entity.UserBaseEO;
import study.cdc.canal.support.blogic.BaseBLogic;
import study.cdc.canal.support.blogic.Table;
import study.cdc.canal.support.utils.ColumnUtils;

import java.util.List;
import java.util.Map;

@Slf4j
@Component
@Table("user_base")
public class UserBaseBLogic extends BaseBLogic {

    @Override
    public void onInsert(List<CanalEntry.Column> afterColumnsLt) {
        UserBaseEO ubEO = ColumnUtils.toBean(afterColumnsLt, UserBaseEO.class);
        log.info("{}", ubEO);
    }

    @Override
    public void onUpdate(List<CanalEntry.Column> beforeColumnsLt, List<CanalEntry.Column> afterColumnsLt) {
        Map<String, Object> d1 = ColumnUtils.toMap(beforeColumnsLt);
        Map<String, Object> d2 = ColumnUtils.toMap(afterColumnsLt);
        log.info("{}", d1);
        log.info("{}", d2);
    }

    @Override
    public void onDelete(List<CanalEntry.Column> beforeColumnsLt) {
        Map<String, Object> d1 = ColumnUtils.toMap(beforeColumnsLt);
        log.info("{}", d1);
    }
}
